home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Programming
/
Programming Languages
/
Yerk 3.64
/
System source
/
Struct1
< prev
next >
Wrap
Text File
|
1991-07-21
|
3KB
|
113 lines
\ struct1 - additional data structures
\ 2/20/85 cbd Version 1
\ 1/17/88 rfl fixed remove: wordcol
\ 3/13/90 rfl at2,to2 in warray
\ 5/23/90 rfl added bytecol
\ 8/08/90 rfl fixed wordcol and bytecol to find negative numbers
\ 9/30/90 rfl added +to: barray;++2,++1
\ 7/21/91 rfl fixed remove: bytecol
Decimal
:CLASS wArray <Super Object 2 <Indexed
:M AT: ?idx at2 ;M
:M TO: ?idx to2 ;M
:M +TO: ?idx ++2 ;M
:M FILL: ?ixObj limit 0
DO dup i to: self LOOP drop ;M
:M PUT: ?ixObj limit 0
DO limit i- 1- (^elem) w! LOOP ;M
\ ( -- e0 e1 ...en) Indexed GET: places elements on stack
:M GET: ?ixObj limit 0 DO i (^elem) w@ LOOP ;M
;CLASS
:CLASS wordCol <Super wArray
Int Size \ # elements in list
\ ( -- curSize ) Return #elements currently in list
:M SIZE: Get: Size ;M
\ ( -- ) set to null list
:M CLEAR: Clear: Size Clear: Super ;M
\ ( -- ^file ) return contents of end of list
:M LAST: get: size dup 0= classerr" 136
1- at: self ;M
\ ( val -- ) Add value to end of list
:M ADD: Get: Size limit >=
classErr" 137 Get: size To: Self
1 +: Size ;M
\ ( ind -- ) remove the element at index
:M REMOVE: { ind -- } ind Get: size >=
classErr" 136 get: size 1- ind
DO i 1+ at: self i to: self LOOP -1 +: size ;M
\ ( val -- ind t OR f) Find a value in an OC
:M INDEXOF: 0 swap Get: Size 0
DO i at2
over = IF 2drop i 1 1 leave THEN
LOOP drop ;M
;CLASS
:CLASS bArray <Super Object 1 <Indexed
:M AT: ?idx at1 ;M
:M TO: ?idx to1 ;M
:M +TO: ?idx ++1 ;M
\ ( val -- )
:M FILL: ?ixObj idxBase limit rot Fill ;M
\ ( e0 e1... en -- ) indexed PUT: loads array from stack
:M PUT: ?ixObj limit 0
DO limit i- 1- to1 LOOP ;M
\ ( -- e0 e1 ...en) Indexed GET: places elements on stack
:M GET: ?ixObj limit 0 DO i at1 LOOP ;M
;CLASS
:CLASS ByteCol <SUPER bArray
Int Size \ # elements in list
( -- curSize ) ( Return #elements currently in list )
:M SIZE: Get: Size ;M
:M SetSize: put: size ;M
( -- ) ( set to null list )
:M CLEAR: Clear: Size Clear: Super ;M
( -- ^file ) ( return contents of end of list )
:M LAST: get: size dup 0= classerr" 136
1- at: self ;M
( val -- ) ( Add value to end of list )
:M ADD: Get: Size limit >=
classErr" 137 Get: size To: Self
1 +: Size ;M
( ind -- ) ( remove the element at index )
:M REMOVE: { ind -- } ind Get: size >=
classErr" 136 Get: size 1- ind
DO I 1+ at: self I to: self LOOP -1 +: size ;M
( val -- ind t OR f) ( Find a value in an OC)
\ even though bytecol recalls as positive numbers, this will
\ find a negative number in the array
:M INDEXOF: dup 0< IF 256 swap + THEN 0 swap Get: Size 0
DO I at1
over = IF 2drop I 1 1 leave THEN
LOOP drop ;M
;CLASS